package com.bjsxt.datastructure.btree;

public class TestLinkedBinaryTree {
    public static void main(String[] args) {

        Node node5 = new Node(5, null, null);
        Node node4 = new Node(4, null, node5);

        Node node3 = new Node(3, null, null);
        Node node7 = new Node(7, null, null);
        Node node6 = new Node(6, null, node7);

        Node node2 = new Node(2, node3, node6);
        Node node1 = new Node(1, node4, node2);

        BinaryTree binaryTree = new LinkedBinaryTree(node1);

        System.out.println(binaryTree.isEmpty());

        //先序遍历

        System.out.println("先序遍历");
        binaryTree.preOrderTraverse();
        binaryTree.preOrderByStack();

        System.out.println();

        //中序遍历
        binaryTree.inOrderTraverse();
        binaryTree.inOrderByStack();

        //后序遍历
        binaryTree.postOrderTraverse();
        binaryTree.postOrderByStack();

        //二叉树的高度
        System.out.println("二叉树的高度为   "  + binaryTree.getHeight());

        //二叉树的节点数
        System.out.println(binaryTree.size());

        //二叉树中查找某个值
        System.out.println(binaryTree.findKey(7));

        //二叉树按照层级遍历
        binaryTree.levelOrderByStack();





    }
}
